package com.unimas.dof.converter;

import javax.servlet.http.HttpServletRequest;

public class IntegerConverter implements Converter {

	public Object convert(Class type, String paramName,HttpServletRequest request) {
		
		String value = request.getParameter(paramName);
		
		if(value == null){
			if(type.equals(int.class)){
				return 0;
			}else{
				return null;
			}
		}else if(value.equalsIgnoreCase("true")){
			return 1;
		}else if(value.equalsIgnoreCase("false")){
			return 0;
		}
		return Integer.parseInt(value);
	}

}
